package com.ssy.lingxi.order.controller.mobile;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.OrderIdVO;
import com.ssy.lingxi.order.model.vo.basic.response.OrderRuleVO;
import com.ssy.lingxi.order.model.vo.common.request.OrderProductHistoryVO;
import com.ssy.lingxi.order.model.vo.common.response.MobileOrderProductHistoryQueryVO;
import com.ssy.lingxi.order.model.vo.common.response.OrderAfterSalePaymentDetailVO;
import com.ssy.lingxi.order.model.vo.mobile.request.MobileOrderAfterSaleVO;
import com.ssy.lingxi.order.model.vo.mobile.response.MobileAfterSalePageQueryVO;
import com.ssy.lingxi.order.service.mobile.IMobileOrderCommonService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu App - 订单相关的公用接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-09-26
 */
@RestController
@RequestMapping("/order/mobile/common")
public class MobileOrderCommonController {
    @Resource
    private IMobileOrderCommonService mobileOrderCommonService;

    /**
     * “商品详情” - 分页查询商品交易记录
     * @param headers Http头部信息
     * @param historyVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/product/history/page", method = RequestMethod.GET)
    Wrapper<PageData<MobileOrderProductHistoryQueryVO>> pageOrderProductHistories(@RequestHeader HttpHeaders headers, @Valid OrderProductHistoryVO historyVO) {
        return mobileOrderCommonService.pageOrderProductHistories(headers, historyVO);
    }

    /**
     * “申请售后” - 查询订单商品信息
     * @param headers Http头部信息
     * @param afterSaleVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/after/sale", method = RequestMethod.GET)
    public Wrapper<MobileAfterSalePageQueryVO> findAfterSaleOrder(@RequestHeader HttpHeaders headers, @Valid MobileOrderAfterSaleVO afterSaleVO) {
        return mobileOrderCommonService.findAfterSaleOrder(headers, afterSaleVO);
    }

    /**
     * 售后能力 - 查询已经确认支付结果的支付记录列表
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/after/sale/payment/find", method = RequestMethod.GET)
    public Wrapper<List<OrderAfterSalePaymentDetailVO>> findAfterSaleOrderPayments(@RequestHeader HttpHeaders headers, @Valid OrderIdVO idVO) {
        return mobileOrderCommonService.findAfterSaleOrderPayments(headers, idVO);
    }

    /**
     * “店铺会员” - 查询平台账户余额类型是否启用
     * @param headers HttpHeaders信息
     * @return 查询结果
     */
    @RequestMapping(value = "/balance/type/find", method = RequestMethod.GET)
    public Wrapper<OrderRuleVO> findPlatformBalanceTypeStatus(@RequestHeader HttpHeaders headers) {
        return mobileOrderCommonService.findPlatformBalanceTypeStatus(headers);
    }
}
